<?php
/**
 * Created by PhpStorm.
 * User: Ruzi
 * Date: 2015/12/10
 * Time: 13:45
 */

header("Content-type: application/json; charset=utf-8");
header("Access-Control-Allow-Origin: *");


function check($host,$community){
    $flag=true;
    $sysDescr = @snmpget("$host","$community","system.sysDescr.0",300);

    if(!empty($sysDescr)){
        $flag=true;
    }else{
        $flag=false;
    }

    return $flag;

}




if(isset($_POST["url"])) {
    $url = $_POST["url"];

    $flag = check("$url", "public");
    $sc = true;
    if ($flag) {
        $sc = true;
    } else {
        $sc = false;
    }

     $arr=array("success"=>$sc);

    echo json_encode($arr);

}
